home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Original Shareware 1.1
/
The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso
/
15
/
marylamb.zip
/
MUSIC.C
< prev
next >
Wrap
C/C++ Source or Header
|
1986-11-16
|
5KB
|
181 lines
/* */
/* Library application source file. */
/* */
/*
* Application Note 10. Windows "Library" utility.
*
*
* Author: John C. Pollock
* OEM Customer Support Engineer
* Date: 1-5-85
* Processor: IBM AT. 640K EGA w/ Enhanced Color Display
*
*
* This application demonstrates how a windows code library should
* be built. LIBRARY is a poor name since what is actually built is
* a sharable executable .EXE file.
*
*/
#include "windows.h"
#include "tunes.h"
extern FAR PASCAL LocalInit();
#ifdef COMMENT
The body of a Windows sharable code library is illustrated by LIBRARY.C.
library.obj: library.c
cc -u -c -AM -Gsw -Oas -Zped library.c
The entry point for the library is "main()". "main()" is called when
the library is first loaded into memory by the Windows loader. The
use of "main()" as the library entry point is arbitrary. Any procedure
may be used as an entry point. The entrypoint is specified by a
"module definition entry point" link text record. The use of "main()"
is convenient since it is familiar to "C" programmers.
In reality, the entry point for any Microsoft "C" program is "__astart".
"__astart" then calls "main()". The LIBAUX.ASM file shows how one
generates a "module definition entry point" record. Any assembler
"END" directive that contains an identifier, e.g. "END __astart"
generates a "module definition entry point" record.
libaux.obj: libaux.asm
masm -Mx -I.\ -I\LIB -D?MLIBW libaux.asm;
The following link line produces the sharable code library MUSIC.EXE
from LIBRARY.OBJ. Windows will load this code if any dynamic link
records point to it. An object library of "dynamic link records"
is produced by IMPLIB.EXE from LIBRARY.DEF. An application links
to the dynamic link records in MUSIC.LIB rather than to the code
that is in MUSIC.EXE.
music.exe: libaux.obj library.obj library.def
link4 libaux library,music,music/map/li, mlibw mwlibc/nodef, library.def;
mapsym music
implib music.lib library.def
The TESTER.EXE program is a very small windows program that dynamically
links to MUSIC.EXE.
tester.obj: tester.c
cc -u -c -Asnw -Gsw -Oas -Zped tester.c
tester.exe: tester.obj
link4 tester,,,music.lib slibw swlibc/map/li,tester.def;
mapsym tester
#endif
/*
** PlayMusic - Windows music interpreter.
**
** PlayMusic implements a simple Windows music interpreter. The interpreter
** is designed such that each music operand fetches its own arguments and
** increments the music pointer "lpmusic". Operands to the music interpreter
** are negative integers each of which encodes a single Windows SOUND module
** procedure call. Non-negative operands implicitly encode SetVoiceNote
** calls ( since they are the most common calls ).
**
*/
BOOL FAR PASCAL PlayMusic( lpmusic )
LPTUNES lpmusic;
{
NOTES t;
for ( ;; )
switch ( t = *lpmusic++ ) {
case OPENSOUND:
OpenSound();
break;
case CLOSESOUND:
CloseSound();
break;
case SETVOICEQUEUESIZE:
SetVoiceQueueSize( *lpmusic, *(lpmusic+1) );
lpmusic += 2;
break;
case SETVOICEACCENT:
SetVoiceAccent( *lpmusic, *(lpmusic+1), *(lpmusic+2), *(lpmusic+3), *(lpmusic+4) );
lpmusic += 5;
break;
case SETVOICEENVELOPE:
SetVoiceEnvelope( *lpmusic, *(lpmusic+1), *(lpmusic+2) );
lpmusic += 3;
break;
case SETSOUNDNOISE:
SetSoundNoise( *lpmusic, *(lpmusic+1) );
lpmusic += 2;
break;
case SETVOICESOUND:
SetVoiceSound( *lpmusic, *(lpmusic+1), *(lpmusic+2) );
lpmusic += 3;
break;
case STARTSOUND:
StartSound();
break;
case STOPSOUND:
return StopSound();
case WAITSOUNDSTATE:
WaitSoundState( *lpmusic++ );
break;
case SYNCALLVOICES:
SyncAllVoices();
break;
case COUNTVOICENOTES:
CountVoiceNotes( *lpmusic++ );
break;
case GETTHRESHOLDEVENT:
GetThresholdEvent();
break;
case GETTHRESHOLDSTATUS:
GetThresholdStatus();
break;
case SETVOICETHRESHOLD:
SetVoiceThreshold( *lpmusic, *(lpmusic+1) );
lpmusic += 2;
break;
default:
SetVoiceNote( t, *lpmusic, *(lpmusic+1), *(lpmusic+2) );
lpmusic += 3;
break;
}
}
HANDLE modulehandle;
int FAR PASCAL main( argc, argv )
register int argc;
HANDLE FAR *argv;
{
/*
ArgC == 5;
ArgV+0 - automatic data segment.
ArgV+1 - size of heap.
ArgV+2 - module handle.
ArgV+3:4 - command line farp.
*/
if ( *argv )
/* Initialize DS ( *argv ) to have local heap of *(argv+1) size. */
LocalInit( (WORD)*argv, (char NEAR *)0, (char NEAR *)*(argv+1) );
modulehandle = *(argv+2);
}